import random
import time
from common.base import BaseMethod


class AddUsers(BaseMethod):

    # 进入会员添加页面
    def goToAddUserPage(self):
        self.click("xpath","//div[@id='menu']/ul/li[2]/a")
        self.click("xpath","//span[text()='添加会员']")

    # 输入用户名
    def input_用户名(self,name):
        self.inputKeys("name","user_name",name)

    # 输入邮箱
    def input_邮箱(self,email):
        self.inputKeys("name", "email", email)

    # 输入密码
    def input_密码(self,passwd):
        self.inputKeys("name", "password", passwd)

    # 输入确认密码
    def input_确认密码(self,passwd):
        self.inputKeys("name", "repassword", passwd)

    # 选择地址
    def select_地区(self):
        self.click("xpath","//*[@id='province']/option[7]")
        time.sleep(1)
        self.click("xpath","//*[@id='city']/option[7]")
        time.sleep(1)
        self.click("xpath","//*[@id='area']/option[7]")

    # 点击确定按钮
    def click_确定(self):
        self.click("xpath","//button")

    #按照要求输入正确的用户数据
    def input_全部用户数据(self):
        m = random.randint(100,100000)
        self.input_用户名("liub"+str(m))
        self.input_邮箱("ss{}@163.com".format(str(m)))
        self.input_密码("123456")
        self.input_确认密码("123456")
        self.select_地区()
